/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package quanlysieuthi;
import DTO.*;
import DAO.*;
import Model.CModel;
import java.awt.event.ItemEvent;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;

public class FrmXuatHang extends javax.swing.JFrame {
    
    /**
     * Creates new form FrmXuatHang
     */
    public FrmXuatHang(FrmMenu _menu) {
        initComponents();
        this.dtcNgayGiao.setDateFormatString(QuanLySieuThi.formatDate);
        this.dtcNgay_tao.setDateFormatString(QuanLySieuThi.formatDate);
        //this.defaultValue();
        loadCombobox();
        //unSetEnabled();
        this.isSetEnabled(true);      
        this._menu = _menu;
    }
    FrmMenu _menu = null;
    DecimalFormat df = new DecimalFormat("#,###");      
    /**
    * Khai báo biến
    */
     List<CSanPham>lSanPham = new ArrayList<CSanPham>();
     List<CTon_Kho> lton_kho = new ArrayList<CTon_Kho>();
     CKho cua_hang = null;
     List<CChiTietHoaDon> listChiTiet = new ArrayList<CChiTietHoaDon>();
     List<CKho> lCuaHang = new ArrayList<CKho>();
     List<CKho> lKho = new ArrayList<CKho>();
     CHoaDon hoadon = new CHoaDon();
     CHoaDon hdCurrent = null;
     String phieu ="PX";
     public Boolean add = false;///khi nhấn nút thêm mới thì bắt chức năng là true. Chức năng đang ở trạng thái thêm mới 1 hóa đơn
     public Boolean edit = false;///khi nhấn nút sửa bật trạng thái là true. Chức năng hiện lên đang ở trạng thái cập nhật
     public Boolean delete = false;
     List<CNhanVien> lNhanvien = new ArrayList<CNhanVien>();
     List<CTinhTrang> ltinh_trang = new ArrayList<CTinhTrang>();
     List<CHoaDon>lhoa_don = new ArrayList<CHoaDon>();
     int currentIndex = 0;// lưu vị trị hiện tại của dòng
     int numberRow = 0;//tổng số dòng của hóa đơn
     long id = -1;
     List<CChiTietHoaDon> lcthd;
     CSanPham sanphamCurrent = null;
     List<CTon_Kho> lkho_nhap = new ArrayList<CTon_Kho>();
     List<CTon_Kho> lkho_xuat = new ArrayList<CTon_Kho>();
     List<CGiaBan>lGiaBan = new ArrayList<CGiaBan>();
     private void defaultValue(){
         this.dtcNgay_tao.setDate(new Date());
         this.dtcNgay_tao.setEnabled(false);
         dtcNgayGiao.setDate(new Date());
         txtNVNhap.setText(QuanLySieuThi.ho_ten);
         cbbKho.setEnabled(true);
         this.cbbCuaHang.setEnabled(true);
         this.cbbNhan_vien.setEnabled(true);
         this.cbbSanPham.setEnabled(true);
         this.cbbTinhTrangPhieu.setEnabled(true);
     }
     
     private void loadCombobox(){
         CModel _model = new CModel(QuanLySieuThi.user_name);
         SubConfig config = SubConfig.getInstance();
         config.init();
        CGiaBanDAO giabanDAO = new CGiaBanDAO();
        this.lGiaBan = giabanDAO.getAll(config); 
        
         lNhanvien = _model.getNhanVien();
         this.cbbNhan_vien.removeAllItems();
         for(CNhanVien nv : lNhanvien){
             this.cbbNhan_vien.addItem(nv.getHoTen());
         }
         this.cbbCuaHang.removeAllItems();
         this.lCuaHang = _model.getKho(true);
         for(CKho item : lCuaHang){
            this.cbbCuaHang.addItem(item.getTenKho());
         }         
         this.cbbKho.removeAllItems();
         this.lKho = _model.getKho(false);
         for(CKho item : lKho){
            this.cbbKho.addItem(item.getTenKho());
         }
        this.cbbTinhTrangPhieu.removeAllItems();
        this.ltinh_trang = _model.getTinhTrang();
        for(CTinhTrang item : ltinh_trang){
            this.cbbTinhTrangPhieu.addItem(item.getTen());
        }
        cbbSanPham.removeAllItems();
        this.lSanPham = _model.getSanPham();
        for(CSanPham item : this.lSanPham){
            this.cbbSanPham.addItem(item.getTenSanPham());
        }
        this.loadDataHoaDon(_model);
        lton_kho = _model.getTonKho();
       // _model.updateAllSanPhamKho();//updateAllSanPhamKho
        config.close();
        _model.Close();
     }
     
     private void loadDataHoaDon(CModel _model){
        this.lhoa_don = _model.getHoaDon(phieu);
        numberRow = lhoa_don.size();
        this.currentIndex = 0;
        this.view(currentIndex);
     }
     
     private void view(int index){
         hdCurrent = null;
         if(index >= 0 && index < numberRow){
            CHoaDon item = this.lhoa_don.get(index);
            hdCurrent = item;
            id = item.getId();
            this.dtcNgayGiao.setDate(item.getNgayNhap());
            this.dtcNgay_tao.setDate(item.getNgayTao());
            CModel _model = new CModel(QuanLySieuThi.user_name);
            int i = _model.indexNhanVien(lNhanvien, item.getNguoilapId());
            if(i>=0 && i< lNhanvien.size()){
                CNhanVien nhlap = lNhanvien.get(i);
                txtNVNhap.setText(nhlap.getHoTen());
            }
            i = _model.indexNhanVien(lNhanvien, item.getNguoiGiaoId());
            this.cbbNhan_vien.setSelectedIndex(i);
            //xet kho
            i = _model.indexKho(lCuaHang, item.getKhoId());
            this.cbbCuaHang.setSelectedIndex(i);
            i = _model.indexKho(lKho, item.getKhachHangId());
            this.cbbKho.setSelectedIndex(i);
            
            lcthd = _model.getChiTiet(id);            
            this.LoadDataTable(lcthd);
            txtRows.setText(String.format("%s/%s", index + 1,numberRow));
            this.cbbCuaHang.setEnabled(false);
            this.cbbKho.setEnabled(false);
            this.cbbNhan_vien.setEnabled(false);            
            this.cbbTinhTrangPhieu.setEnabled(false);
         }
         else if(numberRow == 0){
             lcthd = new ArrayList<CChiTietHoaDon>();
             this.LoadDataTable(lcthd);
             txtRows.setText("0/0");
         }
     }
     private void LoadDataTable(List<CChiTietHoaDon> list){
         Vector<Vector> result = new Vector<Vector>();
            int stt = 1;
            for(CChiTietHoaDon item :list){
                Vector<String>row = new Vector<String>();
                row.addElement("" + stt);
                row.addElement("" + item.getTenSanPham());
                row.addElement(""+item.getSoLuong());
                row.addElement(df.format(item.getDongia()));
                row.addElement(df.format(item.getThanhTien()));
                result.addElement(row);
                stt++;
            }
            Vector<String> columnNames = new Vector<String>();
            columnNames.addElement("STT");
            columnNames.addElement("Tên");
            columnNames.addElement("Số lượng");
            columnNames.addElement("Đơn giá");
            columnNames.addElement("Thành tiền");
            DefaultTableModel model = new DefaultTableModel(result, columnNames);     

            this.tbDanhSach.removeAll();
            this.tbDanhSach.setModel(model);        
            this.tbDanhSach.setFillsViewportHeight(true);
            this.tbDanhSach.setEnabled(false);
     }
     
     public Boolean addNew(){
        hoadon = new CHoaDon();
        hoadon.setChietKhau(0.0);
        hoadon.setId(-1);
        long ch_id = 2; 
        long kho_id = 2;
        long nhan_vien_lap_id =  CKiemTra.user_id;
        long nhan_vien_giao_id =1;
        int index = this.cbbCuaHang.getSelectedIndex();
        if(index >= 0){
             ch_id = this.lCuaHang.get(index).getId();             
        }
        index = cbbKho.getSelectedIndex();
        if(index >=0){
            //lKho
            kho_id = lKho.get(index).getId();
        }
        if(listChiTiet.size() == 0){
            JOptionPane.showMessageDialog(this, "Vui lòng nhập ít nhất 1 mặt hàng cho phiếu xuất");
            return false;
        }
        Date d = this.dtcNgayGiao.getDate();
        Timestamp t = new Timestamp(d.getYear(), d.getMonth(), d.getDate(), 0, 0, 0, 0);
        hoadon.setKhachHangId(kho_id);
        hoadon.setKhoId(ch_id);
        hoadon.setLoaiPhieu(phieu);
        hoadon.setNguoiGiaoId(nhan_vien_giao_id);
        hoadon.setNguoiLapId(nhan_vien_giao_id);
        hoadon.setNguoiSua(CKiemTra.user_name);
        hoadon.setNguoiTao(CKiemTra.user_name);
        hoadon.setNgayNhap(t);        
        hoadon.setTongTien(0.0);
        hoadon.setChietKhau(0.0);
        CModel _model = new CModel(QuanLySieuThi.user_name);       
        Boolean flag = _model.InsertXuatHang(hoadon, listChiTiet, lkho_nhap, lkho_xuat);
       if(flag){
           JOptionPane.showMessageDialog(this, "Thêm hóa đơn mới thành công");
           this.loadDataHoaDon(_model);
       }
       else{
           JOptionPane.showMessageDialog(this, "Thất bại");
       }
        //lkho_nhap
         return true;
     }
     private Boolean editRow(){
        Date d = this.dtcNgayGiao.getDate();
        
        if(d == null){
            d = new Date();
        }
        Timestamp t = new Timestamp(d.getYear(),d.getMonth(),d.getDate(),d.getHours(),d.getMinutes(),d.getSeconds(),0);
        this.hdCurrent.setNgayNhap(t);
        CTinhTrang tinhtrang = this.ltinh_trang.get(this.cbbTinhTrangPhieu.getSelectedIndex());
        this.hdCurrent.setTinhTrang((int)tinhtrang.getId());
        
        d = new Date();
        t = new Timestamp(d.getYear(),d.getMonth(),d.getDate(),d.getHours(),d.getMinutes(),d.getSeconds(),0);
        this.hdCurrent.setNgaySua(t);
        CModel _model = new CModel(QuanLySieuThi.user_name);
        Boolean flag = _model.UpdateHoaDon(hdCurrent, lcthd);
        if(flag){
            JOptionPane.showMessageDialog(this, "Cap nhat thanh cong");
        }
        else{
            JOptionPane.showMessageDialog(this, "Cap nhat that bai");
        }
        return true;
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnPrint = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        lblNgayNhap = new javax.swing.JLabel();
        cbbNhan_vien = new javax.swing.JComboBox();
        lblNhanVienNhap = new javax.swing.JLabel();
        txtNVNhap = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        cbbTinhTrangPhieu = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        cbbKho = new javax.swing.JComboBox();
        dtcNgayGiao = new com.toedter.calendar.JDateChooser();
        lblNgayNhap1 = new javax.swing.JLabel();
        dtcNgay_tao = new com.toedter.calendar.JDateChooser();
        lblNhanVienNhap1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        cbbCuaHang = new javax.swing.JComboBox();
        jPanel2 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        cbbSanPham = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        txtSoLuong = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        txtDonGia = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        txtThanhTien = new javax.swing.JTextField();
        btnAddChiTiet = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        btnPrevBegin = new javax.swing.JButton();
        txtRows = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        tbDanhSach = new javax.swing.JTable();
        btnNextEnd = new javax.swing.JButton();
        btnNext = new javax.swing.JButton();
        btnPrev = new javax.swing.JButton();
        btnadd = new javax.swing.JButton();
        btnSua = new javax.swing.JButton();
        btnLuu = new javax.swing.JButton();
        btnDelete = new javax.swing.JButton();
        btnClose = new javax.swing.JButton();

        btnPrint.setText("In Phiếu");
        btnPrint.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPrintActionPerformed(evt);
            }
        });

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel9.setForeground(new java.awt.Color(102, 102, 255));
        jLabel9.setText("PHIẾU XUẤT HÀNG");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Thông tin chung"));

        lblNgayNhap.setText("Ngày giao:");

        cbbNhan_vien.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        lblNhanVienNhap.setText("Nhân viên lập:");

        jLabel1.setText("Tình trạng phiếu:");

        cbbTinhTrangPhieu.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel8.setText("Kho:");

        cbbKho.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        dtcNgayGiao.setDateFormatString("dd-MM-yyyy");

        lblNgayNhap1.setText("Ngày tạo phiếu:");

        dtcNgay_tao.setDateFormatString("dd-MM-yyyy");

        lblNhanVienNhap1.setText("Nhân viên giao:");

        jLabel3.setText("Cửa hàng: ");

        cbbCuaHang.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblNgayNhap1, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(dtcNgay_tao, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblNgayNhap, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(dtcNgayGiao, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addGap(51, 51, 51)
                        .addComponent(cbbKho, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(lblNhanVienNhap))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(lblNhanVienNhap1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cbbNhan_vien, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(10, 10, 10)
                .addComponent(txtNVNhap, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(20, 20, 20)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cbbTinhTrangPhieu, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(38, 38, 38)
                        .addComponent(cbbCuaHang, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGap(20, 20, 20))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblNhanVienNhap)
                            .addComponent(txtNVNhap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3)
                            .addComponent(cbbCuaHang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8)
                            .addComponent(cbbKho, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(cbbTinhTrangPhieu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblNhanVienNhap1)
                            .addComponent(cbbNhan_vien, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblNgayNhap, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(dtcNgayGiao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblNgayNhap1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(dtcNgay_tao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(0, 6, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Chi tiết sản phẩm"));

        jLabel4.setText("Tên hàng:");

        cbbSanPham.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbbSanPham.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbSanPhamItemStateChanged(evt);
            }
        });

        jLabel5.setText("Số lượng nhập:");

        txtSoLuong.setText("0");
        txtSoLuong.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtSoLuongKeyReleased(evt);
            }
        });

        jLabel6.setText("Đơn giá:");

        txtDonGia.setText("0");
        txtDonGia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtDonGiaActionPerformed(evt);
            }
        });

        jLabel7.setText("Thành tiền:");

        txtThanhTien.setText("0");

        btnAddChiTiet.setText("Thêm chi tiết");
        btnAddChiTiet.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddChiTietActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(cbbSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel5)
                .addGap(18, 18, 18)
                .addComponent(txtSoLuong, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtDonGia, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(txtThanhTien, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btnAddChiTiet, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel4)
                .addComponent(cbbSanPham, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel5)
                .addComponent(txtSoLuong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel6)
                .addComponent(txtDonGia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel7)
                .addComponent(txtThanhTien, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(btnAddChiTiet))
        );

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Danh sách sản phẩm"));

        btnPrevBegin.setText("<<");
        btnPrevBegin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPrevBeginActionPerformed(evt);
            }
        });

        tbDanhSach.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(tbDanhSach);

        btnNextEnd.setText(">>");
        btnNextEnd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNextEndActionPerformed(evt);
            }
        });

        btnNext.setText(">|");
        btnNext.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNextActionPerformed(evt);
            }
        });

        btnPrev.setText("|<");
        btnPrev.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPrevActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(542, 542, 542)
                        .addComponent(btnPrev)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnPrevBegin)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtRows, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnNextEnd)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnNext)))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 218, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnPrev)
                    .addComponent(btnPrevBegin)
                    .addComponent(txtRows, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnNextEnd)
                    .addComponent(btnNext))
                .addGap(12, 12, 12))
        );

        btnadd.setText("Thêm mới");
        btnadd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnaddActionPerformed(evt);
            }
        });

        btnSua.setText("Sửa");
        btnSua.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSuaActionPerformed(evt);
            }
        });

        btnLuu.setText("Lưu");
        btnLuu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLuuActionPerformed(evt);
            }
        });

        btnDelete.setText("Xóa");

        btnClose.setText("Thoát");
        btnClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCloseActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(12, 12, 12)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jLabel9)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnadd)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnSua)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnLuu)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnDelete)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnClose)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnPrint))
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(13, 13, 13))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(24, 24, 24)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(24, 24, 24)
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnadd)
                    .addComponent(btnSua)
                    .addComponent(btnLuu)
                    .addComponent(btnDelete)
                    .addComponent(btnClose)
                    .addComponent(btnPrint))
                .addContainerGap())
        );

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void txtDonGiaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtDonGiaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtDonGiaActionPerformed

    private void btnAddChiTietActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddChiTietActionPerformed
        // TODO add your handling code here:
        addChiTiet();
    }//GEN-LAST:event_btnAddChiTietActionPerformed

    private void clearText(){
        
    }
    private void btnaddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnaddActionPerformed
        // TODO add your handling code here:
        this.clearText();
        this.defaultValue();
        this.add = true;
        this.edit = false;
        this.isSetEnabled(false);
        listChiTiet = new ArrayList<CChiTietHoaDon>();
        this.LoadDataTable(listChiTiet);
    }//GEN-LAST:event_btnaddActionPerformed
    
    private void isSetEnabled(boolean b){        
        this.btnadd.setEnabled(b);
        this.btnSua.setEnabled(b);
        this.btnDelete.setEnabled(b);        
        this.btnSua.setEnabled(b);
        boolean flag = b == true ? false : true;
        this.btnAddChiTiet.setEnabled(flag);
        this.btnLuu.setEnabled(flag);
    }
    private void addChiTiet(){
        CChiTietHoaDon chitiet = new CChiTietHoaDon();
        CTon_Kho tkho = new CTon_Kho();
        int index = this.cbbSanPham.getSelectedIndex();
        sanphamCurrent = new CSanPham();
        String ten_san_pham ="";
        long sanphamId = 1;
        if(index >=0 && index < this.lSanPham.size()){
            sanphamCurrent = this.lSanPham.get(index);
            sanphamId = sanphamCurrent.getId();
            ten_san_pham = sanphamCurrent.getTenSanPham();
        }
      
        CKho kho_current = null;
        index = this.cbbKho.getSelectedIndex();
        long kho_id = -1;
        if(index >=0 && index < this.lKho.size()){
            kho_current = this.lKho.get(index);
            kho_id = kho_current.getId();
            System.out.println("kho id " + kho_id);
        }
        
        long kho_ch_id = 0;
        index = this.cbbCuaHang.getSelectedIndex();
        CKho cua_hang_curr = new CKho();
        
        if(index >=0 && index < this.lCuaHang.size()){
            cua_hang_curr = this.lCuaHang.get(index);
            kho_ch_id = cua_hang_curr.getId();
        }
        
        CModel _model = new CModel(QuanLySieuThi.user_name);
        CTonKhoDAO tonkhoDAO = new CTonKhoDAO();
        CTon_Kho temp = new CTon_Kho();
        temp.setId(kho_id);
        temp.setKhoId(kho_id);
        temp.setSanPhamId(sanphamId);
        CTon_Kho find_tkho = tonkhoDAO.Find(temp, lton_kho);//_model.findTonKho(sanphamId, kho_id);
        temp.setId(kho_ch_id);
        temp.setKhoId(kho_ch_id);
        CTon_Kho f_cua_hang = tonkhoDAO.Find(temp, lton_kho);
        int so_luong = Integer.parseInt(this.txtSoLuong.getText().trim());   
        int sl_ton = find_tkho.getSoLuongNhap() - find_tkho.getSoLuongXuat();
        int index_ct = this.indexOf(listChiTiet, sanphamId);
        if(index_ct !=-1){
            so_luong+= listChiTiet.get(index_ct).getSoLuong();
        }
        //this.listChiTiet.add(chitiet);
        if(so_luong > sl_ton){
            //JOptionPane.showInputDialog("Khong du so luong");
            JOptionPane.showMessageDialog(this, String.format("Trong kho chỉ còn %s không đủ số lượng để xuất", sl_ton));
            return;
        }
        String value = this.txtDonGia.getText().trim();
        value = value.replaceAll(",", "");
        Double don_gia = Double.parseDouble(value);
        double thanh_tien = 0.0;
        //kiem tra cua hang
        if(!CKiemTra.isKiemTraSLNhapToiThieu(f_cua_hang)){            
            JOptionPane.showMessageDialog(this, " Sản phẩm vẫn còn từ từ nhập");
            return;
        }
        thanh_tien = so_luong * don_gia;
        if(CKiemTra.isKiemTraSoLuongNhap(f_cua_hang, so_luong)){
            if(index_ct!= -1){
                listChiTiet.get(index_ct).setSoLuong(so_luong);
                chitiet.setThanhTien(thanh_tien);
            }
            else{
                chitiet.setSoLuong(so_luong);                
                chitiet.setDongia(don_gia);
                chitiet.setHoaDonId(1);
                chitiet.setTenSanPham(ten_san_pham);                                
                chitiet.setThanhTien(thanh_tien);
                chitiet.setTenSanPham(ten_san_pham);
                chitiet.setSanPhamId(sanphamId);
                this.listChiTiet.add(chitiet);
            }
            CTon_Kho k_nhap = new CTon_Kho();//nhap vao cua hang
            CTon_Kho k_xuat = new CTon_Kho();//kho xuat hang cho cua hang
            k_nhap.setKhoId(kho_ch_id);
            k_nhap.setSanPhamId(sanphamId);
            int _sl = 0;
            _sl = so_luong + f_cua_hang.getSoLuongNhap();
            k_nhap.setSoLuongNhap(_sl);
            k_nhap.setSoLuongXuat(f_cua_hang.getSoLuongNhap());
            this.lkho_nhap.add(k_nhap);
            
            k_xuat.setKhoId(kho_id);
            k_xuat.setSanPhamId(sanphamId);            
            _sl = so_luong + f_cua_hang.getSoLuongXuat();
            k_xuat.setSoLuongNhap(find_tkho.getSoLuongNhap());
            k_xuat.setSoLuongXuat(_sl);
            this.lkho_xuat.add(k_xuat);
        }
        else{
            JOptionPane.showMessageDialog(this, "Vượt mức số lượng tồn tối đa... " + f_cua_hang.getTonToiDa());
        }
        this.LoadDataTable(listChiTiet);
    }
    
    private int indexOf(List<CChiTietHoaDon>list,long san_pham_id){
        for(int i = 0; i < list.size();i++){
            CChiTietHoaDon item = list.get(i);
            if(item.getSanPhamId() == san_pham_id){
                return i;
            }
        }
        return -1;
    }
    
    private void btnCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCloseActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
    }//GEN-LAST:event_btnCloseActionPerformed

    private void btnSuaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSuaActionPerformed
        // TODO add your handling code here:
        this.isSetEnabled(false);
        this.add = false;
        this.edit = true;
        this.defaultValue();
    }//GEN-LAST:event_btnSuaActionPerformed

    private void btnLuuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLuuActionPerformed
        // TODO add your handling code here:
        boolean flag = false;
        if(this.add){
            flag = addNew();
        }
        else if(this.edit){
            flag = this.editRow();
        }
        if(flag){
            if(this._menu != null){
                this._menu.loadTonKho();
            }
            this.isSetEnabled(true);
            this.add = false;
            this.edit = false;
        }
    }//GEN-LAST:event_btnLuuActionPerformed

     private CGiaBan getItemGiaBan(long san_pham_id){
        for(CGiaBan item : this.lGiaBan){
            if(item.getSanPhamId() == san_pham_id){
                return item;
            }
        }
        return null;
    }
     
    private void cbbSanPhamItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbSanPhamItemStateChanged
        // TODO add your handling code here:
        try{
            if(evt.getStateChange() == ItemEvent.SELECTED){
                int index = this.cbbSanPham.getSelectedIndex();
                                
                if(index >=0 && index < this.lSanPham.size()){                    
                    sanphamCurrent = this.lSanPham.get(index); 
                    CGiaBan gbCurrent = this.getItemGiaBan(sanphamCurrent.getId());
                    double dgnhap = sanphamCurrent.getGiaNhap();
                    if(gbCurrent!= null){
                        dgnhap =gbCurrent.getGiaNhap() ;
                    }
                    System.out.println("gia nhap : " + gbCurrent.getGiaNhap());
                    txtDonGia.setText(df.format(dgnhap));
                }
            }
        }
        catch(Exception error){
            
        }
    }//GEN-LAST:event_cbbSanPhamItemStateChanged

    private void btnPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrintActionPerformed
        // TODO add your handling code here:
       String fileName ="src/report/chitietxuathang.jrxml" ;        
       HashMap parameters = new HashMap();
        //parameters.put("title", title);
       parameters.put("p_tencuahang",this.cbbCuaHang.getSelectedItem().toString());
       parameters.put("p_tenkho",this.cbbKho.getSelectedItem().toString());
       parameters.put("p_khuyenmai","");
       parameters.put("p_sophieuxh",this.id);
       Date d = this.dtcNgay_tao.getDate();
       int year = d.getYear() + 1900;
       String ngayban = d.getDate() + "-" + d.getMonth() + "-" + year ;
       parameters.put("p_ngayxuat",ngayban);       
       parameters.put("p_nvgiao",this.cbbNhan_vien.getSelectedItem().toString());
       parameters.put("p_nvlap",this.txtNVNhap.getText());
       JRBeanCollectionDataSource collectionDataSource = new JRBeanCollectionDataSource(this.lcthd);
       FrmReport f = null;// new FrmReport(begin, end, kho, loai_phieu, fileName, title,theo);
       f = new FrmReport(collectionDataSource, fileName, parameters);
       f.setVisible(true);
    }//GEN-LAST:event_btnPrintActionPerformed

    private void btnPrevActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrevActionPerformed
        // TODO add your handling code here:
        if(currentIndex > 0){
            currentIndex--;
            this.view(currentIndex);
        }
    }//GEN-LAST:event_btnPrevActionPerformed

    private void btnNextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNextActionPerformed
        // TODO add your handling code here:
         if(this.currentIndex < this.numberRow){
            this.currentIndex++;
            this.view(this.currentIndex);
        }
    }//GEN-LAST:event_btnNextActionPerformed

    private void btnPrevBeginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPrevBeginActionPerformed
        this.currentIndex = 0;
         this.view(this.currentIndex);
    }//GEN-LAST:event_btnPrevBeginActionPerformed

    private void btnNextEndActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNextEndActionPerformed
       this.currentIndex = this.numberRow - 1;
         this.view(this.currentIndex);
    }//GEN-LAST:event_btnNextEndActionPerformed

    private void txtSoLuongKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtSoLuongKeyReleased
        // TODO add your handling code here:
         try{
            if(!txtSoLuong.getText().equals("")){
                int sl = Integer.parseInt(txtSoLuong.getText());
                String value = txtDonGia.getText().replaceAll(",", "");
                double don_gia = Double.parseDouble(value);
                double thanh_tien = sl * don_gia;
                txtThanhTien.setText(String.format("%s",df.format(thanh_tien)));
            }
            
        } catch(Exception error){
            
        }
    }//GEN-LAST:event_txtSoLuongKeyReleased

    /**
     * @param args the command line arguments
     */
    
   // public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
    /*
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrmXuatHang.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrmXuatHang.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrmXuatHang.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrmXuatHang.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }*/
        //</editor-fold>

        /* Create and display the form */
        /*
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FrmXuatHang().setVisible(true);
            }
        });
    }*/
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAddChiTiet;
    private javax.swing.JButton btnClose;
    private javax.swing.JButton btnDelete;
    private javax.swing.JButton btnLuu;
    private javax.swing.JButton btnNext;
    private javax.swing.JButton btnNextEnd;
    private javax.swing.JButton btnPrev;
    private javax.swing.JButton btnPrevBegin;
    private javax.swing.JButton btnPrint;
    private javax.swing.JButton btnSua;
    private javax.swing.JButton btnadd;
    private javax.swing.JComboBox cbbCuaHang;
    private javax.swing.JComboBox cbbKho;
    private javax.swing.JComboBox cbbNhan_vien;
    private javax.swing.JComboBox cbbSanPham;
    private javax.swing.JComboBox cbbTinhTrangPhieu;
    private com.toedter.calendar.JDateChooser dtcNgayGiao;
    private com.toedter.calendar.JDateChooser dtcNgay_tao;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblNgayNhap;
    private javax.swing.JLabel lblNgayNhap1;
    private javax.swing.JLabel lblNhanVienNhap;
    private javax.swing.JLabel lblNhanVienNhap1;
    private javax.swing.JTable tbDanhSach;
    private javax.swing.JTextField txtDonGia;
    private javax.swing.JTextField txtNVNhap;
    private javax.swing.JTextField txtRows;
    private javax.swing.JTextField txtSoLuong;
    private javax.swing.JTextField txtThanhTien;
    // End of variables declaration//GEN-END:variables
}
